package tabinactivity.eastandroid.com;

import android.app.ActivityGroup;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.widget.Toast;

public class BaseTabActivity extends ActivityGroup {

	protected Context mContext;
	protected static SharedPreferences mPreferences;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mContext = this;

		mPreferences = PreferenceManager.getDefaultSharedPreferences(this);

		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
	}

	@Override
	public void startActivityForResult(Intent intent, int requestCode) {
		try {
			Log.l(intent.toString());
			super.startActivityForResult(intent, requestCode);
		} catch (ActivityNotFoundException e) {
			Toast.makeText(mContext, e.getMessage(), Toast.LENGTH_LONG).show();
		}
	}

	public void showDialog(String message, String positiveButtonText, DialogInterface.OnClickListener positiveListener) {
		new AlertDialog.Builder(mContext).setMessage(message).setPositiveButton(positiveButtonText, positiveListener).create().show();
	}
	public void showDialog(String message, String positiveButtonText, DialogInterface.OnClickListener positiveListener, String negativeButtonText, DialogInterface.OnClickListener negativeListener) {
		new AlertDialog.Builder(mContext).setMessage(message).setPositiveButton(positiveButtonText, positiveListener).setNegativeButton(negativeButtonText, negativeListener).create().show();
	}
	public void showList(int array_resid, DialogInterface.OnClickListener onItemclickedListener) {
		new AlertDialog.Builder(mContext).setItems(array_resid, onItemclickedListener).create().show();
	}
	public void showList(CharSequence[] items, DialogInterface.OnClickListener onItemclickedListener) {
		new AlertDialog.Builder(mContext).setItems(items, onItemclickedListener).create().show();
	}
	public void showList(CharSequence title, CharSequence[] items, DialogInterface.OnClickListener onItemclickedListener) {
		new AlertDialog.Builder(mContext).setTitle(title).setItems(items, onItemclickedListener).create().show();
	}

}